<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>SpringBoot整合WebService | 牛牛&amp;blog</title><meta name="author" content="牛牛"><meta name="copyright" content="牛牛"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="SpringBoot整合WebService一、使用JDK自带的JAX-WS发布WebService服务1、通过maven创建普通的java项目  2、编写接口和实现类:  HelloService.java接口 package com.ransib.service;&#x2F;** * @description: * @author: rsb * @description: 2023-06-20-16-3">
<meta property="og:type" content="article">
<meta property="og:title" content="SpringBoot整合WebService">
<meta property="og:url" content="https://code-ran.gitee.io/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/index.html">
<meta property="og:site_name" content="牛牛&amp;blog">
<meta property="og:description" content="SpringBoot整合WebService一、使用JDK自带的JAX-WS发布WebService服务1、通过maven创建普通的java项目  2、编写接口和实现类:  HelloService.java接口 package com.ransib.service;&#x2F;** * @description: * @author: rsb * @description: 2023-06-20-16-3">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="">
<meta property="article:published_time" content="2023-07-03T08:12:34.000Z">
<meta property="article:modified_time" content="2023-11-02T03:32:07.098Z">
<meta property="article:author" content="牛牛">
<meta property="article:tag" content="WebService相关">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content=""><link rel="shortcut icon" href="/img/myfavicon.png"><link rel="canonical" href="https://code-ran.gitee.io/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'SpringBoot整合WebService',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-11-02 11:32:07'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/style.css"><meta name="generator" content="Hexo 5.4.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><script>const preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',()=> { preloader.endLoading() })

if (false) {
  document.addEventListener('pjax:send', () => { preloader.initLoading() })
  document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}</script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/ys.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">52</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">26</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">26</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">牛牛&amp;blog</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">SpringBoot整合WebService</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-07-03T08:12:34.000Z" title="发表于 2023-07-03 16:12:34">2023-07-03</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-11-02T03:32:07.098Z" title="更新于 2023-11-02 11:32:07">2023-11-02</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/WebService/">WebService</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="SpringBoot整合WebService"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h4 id="SpringBoot整合WebService"><a href="#SpringBoot整合WebService" class="headerlink" title="SpringBoot整合WebService"></a>SpringBoot整合WebService</h4><h5 id="一、使用JDK自带的JAX-WS发布WebService服务"><a href="#一、使用JDK自带的JAX-WS发布WebService服务" class="headerlink" title="一、使用JDK自带的JAX-WS发布WebService服务"></a>一、使用JDK自带的JAX-WS发布WebService服务</h5><p>1、通过maven创建普通的java项目</p>
<p><img src="/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/image-20230620170436731.png" alt="image-20230620170436731"></p>
<p>2、编写接口和实现类:</p>
<p><img src="/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/image-20230620170548670.png" alt="image-20230620170548670"></p>
<p>HelloService.java接口</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">package</span> com.ransib.service;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>:</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span>: rsb</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>: 2023-06-20-16-36</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>:</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Version</span>: 1.0.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">interface</span> <span class="title">HelloService</span> </span>&#123;</span><br><span class="line">    <span class="function">String <span class="title">sayHello</span><span class="params">(String name)</span></span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>HelloService的实现HelloServiceImpl.java</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">package</span> com.ransib.service.impl;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.ransib.service.HelloService;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> javax.jws.WebMethod;</span><br><span class="line"><span class="keyword">import</span> javax.jws.WebParam;</span><br><span class="line"><span class="keyword">import</span> javax.jws.WebResult;</span><br><span class="line"><span class="keyword">import</span> javax.jws.WebService;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>:</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span>: rsb</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>: 2023-06-20-16-36</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>: 使用JDK自带的 JAX-WS 发布WebService服务</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Version</span>: 1.0.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@WebService</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">HelloServiceImpl</span> <span class="keyword">implements</span> <span class="title">HelloService</span> </span>&#123;</span><br><span class="line">    <span class="meta">@WebMethod</span></span><br><span class="line">    <span class="meta">@WebResult(name = &quot;resultName&quot;)</span></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">sayHello</span><span class="params">(<span class="meta">@WebParam(name = &quot;name&quot;)</span> String name)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;Hello ,&quot;</span> + name;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>编写启动类WsPublish.java</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">package</span> com.ransib;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.ransib.service.impl.HelloServiceImpl;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> javax.xml.ws.Endpoint;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>:</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span>: rsb</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>: 2023-06-20-16-40</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>: 使用JDK自带的 JAX-WS 发布WebService服务</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Version</span>: 1.0.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">WsPublish</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        String address = <span class="string">&quot;http://localhost:8888/ws&quot;</span>;</span><br><span class="line">        Endpoint.publish(address,<span class="keyword">new</span> HelloServiceImpl());</span><br><span class="line">        System.out.println(<span class="string">&quot;服务已发布&quot;</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>启动项目</p>
<p><img src="/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/image-20230620170902569.png" alt="image-20230620170902569"></p>
<p>访问发布的地址，记得加上wsdl</p>
<p><img src="/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/image-20230620171010440.png" alt="image-20230620171010440"></p>
<p>然后再访问schemaLocation指向的地址:<a target="_blank" rel="noopener" href="http://localhost:8888/ws?xsd=1">http://localhost:8888/ws?xsd=1</a></p>
<p><img src="/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/image-20230620171054409.png" alt="image-20230620171054409"></p>
<h5 id="二、使用CXF发布WebService服务"><a href="#二、使用CXF发布WebService服务" class="headerlink" title="二、使用CXF发布WebService服务"></a>二、使用CXF发布WebService服务</h5><p>1、创建nx-boot-cxfway模块</p>
<p><img src="/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/image-20230625111927614.png" alt="image-20230625111927614"></p>
<p>pom.xml</p>
<figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">project</span> <span class="attr">xmlns</span>=<span class="string">&quot;http://maven.apache.org/POM/4.0.0&quot;</span> <span class="attr">xmlns:xsi</span>=<span class="string">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span></span><br><span class="line"><span class="tag">         <span class="attr">xsi:schemaLocation</span>=<span class="string">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">parent</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-parent<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.6.3<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">relativePath</span>/&gt;</span> <span class="comment">&lt;!-- lookup parent from repository --&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">parent</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">modelVersion</span>&gt;</span>4.0.0<span class="tag">&lt;/<span class="name">modelVersion</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.ransib<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>nx-boot-cxfway<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.0-SNAPSHOT<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">name</span>&gt;</span>nx-boot-cxfway<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- FIXME change it to the project&#x27;s website --&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">url</span>&gt;</span>http://www.example.com<span class="tag">&lt;/<span class="name">url</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">properties</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">maven.compiler.source</span>&gt;</span>8<span class="tag">&lt;/<span class="name">maven.compiler.source</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">maven.compiler.target</span>&gt;</span>8<span class="tag">&lt;/<span class="name">maven.compiler.target</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">properties</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">dependencies</span>&gt;</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">&lt;!-- https://mvnrepository.com/artifact/com.alibaba/fastjson --&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.alibaba<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>fastjson<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.2.79<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        <span class="comment">&lt;!--WebService CXF依赖 begin--&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.cxf<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>cxf-spring-boot-starter-jaxws<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">version</span>&gt;</span>3.5.0<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.cxf<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>cxf-rt-frontend-jaxws<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">version</span>&gt;</span>3.5.0<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.apache.cxf<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>cxf-rt-transports-http<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">version</span>&gt;</span>3.5.0<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">        <span class="comment">&lt;!--WebService CXF依赖 end--&gt;</span></span><br><span class="line"></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-thymeleaf<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-web<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-devtools<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">scope</span>&gt;</span>runtime<span class="tag">&lt;/<span class="name">scope</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">optional</span>&gt;</span>true<span class="tag">&lt;/<span class="name">optional</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>mysql<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>mysql-connector-java<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">scope</span>&gt;</span>runtime<span class="tag">&lt;/<span class="name">scope</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-configuration-processor<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">optional</span>&gt;</span>true<span class="tag">&lt;/<span class="name">optional</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.projectlombok<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>lombok<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">optional</span>&gt;</span>true<span class="tag">&lt;/<span class="name">optional</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-test<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">scope</span>&gt;</span>test<span class="tag">&lt;/<span class="name">scope</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">dependencies</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">build</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">plugins</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">plugin</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-maven-plugin<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;<span class="name">configuration</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;<span class="name">excludes</span>&gt;</span></span><br><span class="line">                        <span class="tag">&lt;<span class="name">exclude</span>&gt;</span></span><br><span class="line">                            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.projectlombok<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">                            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>lombok<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">                        <span class="tag">&lt;/<span class="name">exclude</span>&gt;</span></span><br><span class="line">                    <span class="tag">&lt;/<span class="name">excludes</span>&gt;</span></span><br><span class="line">                <span class="tag">&lt;/<span class="name">configuration</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;/<span class="name">plugin</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">plugins</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">build</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">project</span>&gt;</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>2、application.yml配置</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line">server:</span><br><span class="line">  port: <span class="number">8102</span></span><br><span class="line">spring:</span><br><span class="line">  application:</span><br><span class="line">    name: nx-boot-cxfway</span><br><span class="line">  #遇到相同类名覆盖注册</span><br><span class="line">  main:</span><br><span class="line">    allow-bean-definition-overriding: <span class="keyword">true</span></span><br><span class="line"># 集成cxf,默认：cxf.path=/services</span><br><span class="line">cxf:</span><br><span class="line">  path: /ws</span><br></pre></td></tr></table></figure>

<p>3、编写启动类: Main.java</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">package</span> com.ransib;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> org.springframework.boot.SpringApplication;</span><br><span class="line"><span class="keyword">import</span> org.springframework.boot.autoconfigure.SpringBootApplication;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>:</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span>: rsb</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>: 2023-06-20-16-13</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>:</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Version</span>: 1.0.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@SpringBootApplication</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        SpringApplication.run(Main.class, args);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>3、编写接口</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">package</span> com.ransib.service;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>:</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span>: rsb</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>: 2023-06-20-16-36</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>:</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Version</span>: 1.0.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">interface</span> <span class="title">HelloService</span> </span>&#123;</span><br><span class="line">    <span class="function">String <span class="title">sayHello</span><span class="params">(String name)</span></span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>4、编写实现类: HelloServiceImpl.java</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">package</span> com.ransib.service.impl;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.ransib.service.HelloService;</span><br><span class="line"><span class="keyword">import</span> org.springframework.stereotype.Service;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> javax.jws.WebMethod;</span><br><span class="line"><span class="keyword">import</span> javax.jws.WebParam;</span><br><span class="line"><span class="keyword">import</span> javax.jws.WebResult;</span><br><span class="line"><span class="keyword">import</span> javax.jws.WebService;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>:</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span>: rsb</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>: 2023-06-20-16-36</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>: 使用JDK自带的 JAX-WS 发布WebService服务</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Version</span>: 1.0.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@WebService</span></span><br><span class="line"><span class="meta">@Service</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">HelloServiceImpl</span> <span class="keyword">implements</span> <span class="title">HelloService</span> </span>&#123;</span><br><span class="line">    <span class="meta">@WebMethod</span></span><br><span class="line">    <span class="meta">@WebResult(name = &quot;resultName&quot;)</span></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">sayHello</span><span class="params">(<span class="meta">@WebParam(name = &quot;name&quot;)</span> String name)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;Hello ,&quot;</span> + name;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>5、编写配置类: CxfConfig.java</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">package</span> com.ransib.config;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.ransib.service.impl.HelloServiceImpl;</span><br><span class="line"><span class="keyword">import</span> org.apache.cxf.Bus;</span><br><span class="line"><span class="keyword">import</span> org.apache.cxf.jaxws.EndpointImpl;</span><br><span class="line"><span class="keyword">import</span> org.springframework.beans.factory.annotation.Autowired;</span><br><span class="line"><span class="keyword">import</span> org.springframework.context.annotation.Bean;</span><br><span class="line"><span class="keyword">import</span> org.springframework.context.annotation.Configuration;</span><br><span class="line"><span class="keyword">import</span> javax.xml.ws.Endpoint;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * description: CXF服务发布配置</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@Configuration</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">CxfConfig</span> </span>&#123;</span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    <span class="keyword">private</span> Bus bus;</span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    <span class="keyword">private</span> HelloServiceImpl helloService;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Bean</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> Endpoint <span class="title">helloServer</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        EndpointImpl endpoint = <span class="keyword">new</span> EndpointImpl(bus, helloService);</span><br><span class="line">        <span class="comment">//访问:http://localhost:8102/ws/hello?wsdl</span></span><br><span class="line">        endpoint.publish(<span class="string">&quot;/hello&quot;</span>);</span><br><span class="line">        <span class="keyword">return</span> endpoint;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>6、启动项目，访问<a target="_blank" rel="noopener" href="http://localhost:8102/ws/hello?wsdl">http://localhost:8102/ws/hello?wsdl</a></p>
<p><img src="/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/image-20230625112357691.png" alt="image-20230625112357691"></p>
<p>7、soapui测试</p>
<p><img src="/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/image-20230625112438576.png" alt="image-20230625112438576"></p>
<h5 id="三、动态发布多个WS服务"><a href="#三、动态发布多个WS服务" class="headerlink" title="三、动态发布多个WS服务"></a>三、动态发布多个WS服务</h5><figure class="highlight java"><table><tr><td class="code"><pre><span class="line">   ApplicationRunner 或 CommandLineRunner 使用场景：在Springboot容器启动完毕后要执行一</span><br><span class="line">些特定的业务代码，如读取Redis缓存数据、特定的配置文件、数据库等等相关数据</span><br><span class="line">可以同时配置多个 ApplicationRunner 或 CommandLineRunner ,如果配置了多个则启动的优</span><br><span class="line">先级可以通过 <span class="meta">@Order(1)</span> 来指定，值越小优先级越高</span><br><span class="line">ApplicationRunner 中的run方法接收一个 ApplicationArguments 类型的参数</span><br><span class="line">run(ApplicationArguments args) ，如：当把应用打成一个jar包运行的时候，后面跟着</span><br><span class="line">的命令行参数可以通过ApplicationArguments拿到</span><br><span class="line">CommandLineRunner 中的run方法接收一个String类型的可变参数列表 run(String...</span><br><span class="line">args)</span><br></pre></td></tr></table></figure>

<p>实现方案:</p>
<p>1、自定义动态发布接口的注解</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">package</span> com.ransib.annotation;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.lang.annotation.ElementType;</span><br><span class="line"><span class="keyword">import</span> java.lang.annotation.Retention;</span><br><span class="line"><span class="keyword">import</span> java.lang.annotation.RetentionPolicy;</span><br><span class="line"><span class="keyword">import</span> java.lang.annotation.Target;</span><br><span class="line"></span><br><span class="line"><span class="meta">@Retention(RetentionPolicy.RUNTIME)</span></span><br><span class="line"><span class="meta">@Target(ElementType.TYPE)</span></span><br><span class="line"><span class="keyword">public</span> <span class="meta">@interface</span> AutoPublishWS &#123;</span><br><span class="line">    <span class="function">String <span class="title">publishPath</span><span class="params">()</span></span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<p>2、在业务类中标注自定义动态发布WebService接口的注解: @AutoPublishWS(publishPath = “****”)</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">package</span> com.ransib.service.impl;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.alibaba.fastjson.JSONArray;</span><br><span class="line"><span class="keyword">import</span> com.alibaba.fastjson.JSONObject;</span><br><span class="line"><span class="keyword">import</span> com.ransib.annotation.AutoPublishWS;</span><br><span class="line"><span class="keyword">import</span> com.ransib.service.WSService;</span><br><span class="line"><span class="keyword">import</span> org.springframework.stereotype.Service;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> javax.jws.WebMethod;</span><br><span class="line"><span class="keyword">import</span> javax.jws.WebParam;</span><br><span class="line"><span class="keyword">import</span> javax.jws.WebResult;</span><br><span class="line"><span class="keyword">import</span> javax.jws.WebService;</span><br><span class="line"></span><br><span class="line"><span class="meta">@AutoPublishWS(publishPath = &quot;autoUserInfo&quot;)</span></span><br><span class="line"><span class="meta">@Service</span></span><br><span class="line"><span class="meta">@WebService</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">UserInfoWSServiceImpl</span> <span class="keyword">implements</span> <span class="title">WSService</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@WebMethod</span></span><br><span class="line">    <span class="meta">@WebResult(name = &quot;resultName&quot;)</span></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">sayHello</span><span class="params">(<span class="meta">@WebParam(name = &quot;name&quot;)</span> String name)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> String.format(<span class="string">&quot;hello,%s&quot;</span>,name);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@WebMethod</span></span><br><span class="line">    <span class="meta">@WebResult(name = &quot;userInfo&quot;)</span></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getInfo</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        JSONArray jsonArray = <span class="keyword">new</span> JSONArray();</span><br><span class="line">        JSONObject jsonObject;</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; <span class="number">5</span>; i++) &#123;</span><br><span class="line">            jsonObject = <span class="keyword">new</span> JSONObject();</span><br><span class="line">            jsonObject.put(<span class="string">&quot;userCode&quot;</span>,<span class="string">&quot;code&quot;</span>+(i+<span class="number">1</span>));</span><br><span class="line">            jsonObject.put(<span class="string">&quot;userName&quot;</span>,<span class="string">&quot;用户&quot;</span>+(i+<span class="number">1</span>));</span><br><span class="line">            jsonArray.add(jsonObject);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> jsonArray.toJSONString();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>3、使用Springboot提供的 ApplicationRunner 或 CommandLineRunner 接口来实现当容器启动完毕</p>
<p>后动态发布多个webService接口</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">package</span> com.ransib.config;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.ransib.annotation.AutoPublishWS;</span><br><span class="line"><span class="keyword">import</span> lombok.extern.slf4j.Slf4j;</span><br><span class="line"><span class="keyword">import</span> org.apache.cxf.Bus;</span><br><span class="line"><span class="keyword">import</span> org.apache.cxf.jaxws.EndpointImpl;</span><br><span class="line"><span class="keyword">import</span> org.springframework.beans.factory.annotation.Autowired;</span><br><span class="line"><span class="keyword">import</span> org.springframework.beans.factory.annotation.Value;</span><br><span class="line"><span class="keyword">import</span> org.springframework.boot.ApplicationArguments;</span><br><span class="line"><span class="keyword">import</span> org.springframework.boot.ApplicationRunner;</span><br><span class="line"><span class="keyword">import</span> org.springframework.core.annotation.Order;</span><br><span class="line"><span class="keyword">import</span> org.springframework.core.env.Environment;</span><br><span class="line"><span class="keyword">import</span> org.springframework.stereotype.Component;</span><br><span class="line"><span class="keyword">import</span> org.springframework.web.context.WebApplicationContext;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.net.InetAddress;</span><br><span class="line"><span class="keyword">import</span> java.net.UnknownHostException;</span><br><span class="line"><span class="keyword">import</span> java.util.ArrayList;</span><br><span class="line"><span class="keyword">import</span> java.util.List;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * description: 自动发布</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@Slf4j</span></span><br><span class="line"><span class="meta">@Component</span></span><br><span class="line"><span class="meta">@Order(1)</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">AutoPublishWSEndpoint</span> <span class="keyword">implements</span> <span class="title">ApplicationRunner</span> </span>&#123;</span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 取出WS的根路径</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@Value(&quot;$&#123;cxf.path&#125;&quot;)</span></span><br><span class="line">    <span class="keyword">public</span> String cxfPath;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 取出AppName</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@Value(&quot;$&#123;spring.application.name&#125;&quot;)</span></span><br><span class="line">    <span class="keyword">public</span> String appName;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    <span class="keyword">private</span> Bus bus;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 注入Spring Web中Servlet上下文Web容器</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    <span class="keyword">private</span> WebApplicationContext webApplicationContext;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">run</span><span class="params">(ApplicationArguments args)</span> <span class="keyword">throws</span> Exception </span>&#123;</span><br><span class="line">        log.info(<span class="string">&quot;AutoPublishWSEndpoint===发布开始&quot;</span>);</span><br><span class="line">        <span class="comment">//根据注解获取beanNames</span></span><br><span class="line">        String[] beanNames = webApplicationContext.getBeanNamesForAnnotation(AutoPublishWS.class);</span><br><span class="line">        EndpointImpl endpoint;</span><br><span class="line">        List&lt;String&gt; cxfPathList = <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line">        <span class="keyword">for</span> (String beanName : beanNames) &#123;</span><br><span class="line">            <span class="comment">//根据beanName获取属性名</span></span><br><span class="line">            String publishPath = webApplicationContext.getType(beanName).getAnnotation(AutoPublishWS.class).publishPath();</span><br><span class="line">            <span class="comment">//发布WebService接口</span></span><br><span class="line">            endpoint = <span class="keyword">new</span> EndpointImpl(bus, webApplicationContext.getBean(beanName));</span><br><span class="line">            endpoint.publish(publishPath);</span><br><span class="line">            cxfPathList.add(publishPath);</span><br><span class="line">            log.info(String.format(<span class="string">&quot;%s&quot;</span>, publishPath));</span><br><span class="line">        &#125;</span><br><span class="line">        log.info(<span class="string">&quot;AutoPublishWSEndpoint===发布结束&quot;</span>);</span><br><span class="line">        Environment environment = webApplicationContext.getEnvironment();</span><br><span class="line">        address(environment, cxfPathList);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * description: 打印访问路径</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> environment 运行环境</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> cxfPathList 发布的WS路径</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span> String</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">address</span><span class="params">(Environment environment, List&lt;String&gt; cxfPathList)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            String ip = InetAddress.getLocalHost().getHostAddress();</span><br><span class="line">            String port = environment.getProperty(<span class="string">&quot;server.port&quot;</span>);</span><br><span class="line">            String path = environment.getProperty(<span class="string">&quot;server.servlet.context-path&quot;</span>);</span><br><span class="line">            <span class="keyword">if</span> (path == <span class="keyword">null</span>) &#123;</span><br><span class="line">                path = <span class="string">&quot;&quot;</span>;</span><br><span class="line">            &#125;</span><br><span class="line">            log.info(<span class="string">&quot;\n----------------------------------------------------------\n\t&quot;</span> +</span><br><span class="line">                    <span class="string">&quot;Application &quot;</span> + appName + <span class="string">&quot; is running! Access URLs:\n\t&quot;</span> +</span><br><span class="line">                    <span class="string">&quot;Local: \t\thttp://localhost:&quot;</span> + port + path + <span class="string">&quot;/\n\t&quot;</span> +</span><br><span class="line">                    <span class="string">&quot;External: \thttp://&quot;</span> + ip + <span class="string">&quot;:&quot;</span> + port + path + <span class="string">&quot;/&quot;</span> +</span><br><span class="line">                    <span class="string">&quot;\n----------------------------------------------------------&quot;</span>);</span><br><span class="line">            <span class="keyword">if</span> (cxfPathList.size() &gt; <span class="number">0</span>) &#123;</span><br><span class="line">                StringBuilder logStr = <span class="keyword">new</span> StringBuilder();</span><br><span class="line">                logStr.append(<span class="string">&quot;\n\tWSDL URLS:\n\t&quot;</span>);</span><br><span class="line">                String finalPath = path;</span><br><span class="line">                cxfPathList.forEach(s -&gt; &#123;</span><br><span class="line">                    logStr.append(<span class="string">&quot;\t\thttp://localhost:&quot;</span> + port + finalPath + cxfPath + <span class="string">&quot;/&quot;</span> + s + <span class="string">&quot;?wsdl\n\t&quot;</span>);</span><br><span class="line">                    logStr.append(<span class="string">&quot;\t\thttp://&quot;</span> + ip + <span class="string">&quot;:&quot;</span> + port + finalPath + cxfPath + <span class="string">&quot;/&quot;</span> + s + <span class="string">&quot;?wsdl\n\t&quot;</span>);</span><br><span class="line">                &#125;);</span><br><span class="line">                log.info(logStr.toString());</span><br><span class="line">            &#125;</span><br><span class="line">        &#125; <span class="keyword">catch</span> (UnknownHostException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h5 id="三、服务消费-客户端"><a href="#三、服务消费-客户端" class="headerlink" title="三、服务消费(客户端)"></a>三、服务消费(客户端)</h5><p>1、使用jdk自带的命令生成调用代码:</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">wsimport -keep -encoding utf-8 -verbose http://localhost:8102/ws/hello?wsdl</span><br><span class="line">wsimport -p com.test -keep -encoding utf-8 -verbose http://localhost:8102/ws/userInfo?wsdl</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">package</span> test;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.ransib.service.impl.HelloServiceImpl;</span><br><span class="line"><span class="keyword">import</span> com.ransib.service.impl.HelloServiceImplService;</span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>:</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span>: rsb</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>: 2023-06-25-15-55</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>:</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Version</span>: 1.0.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MyTest</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        HelloServiceImplService helloServiceImplService = <span class="keyword">new</span> HelloServiceImplService();</span><br><span class="line">        HelloServiceImpl servicePort = helloServiceImplService.getHelloServiceImplPort();</span><br><span class="line">        String <span class="keyword">var</span> = servicePort.sayHello(<span class="string">&quot;张三&quot;</span>);</span><br><span class="line">        System.out.println(<span class="string">&quot;====调用成功====&quot;</span>+<span class="keyword">var</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>2、使用cxf的wsdl命令生成调用代码：</p>
<p>官网:<a target="_blank" rel="noopener" href="https://cxf.apache.org/download.html">https://cxf.apache.org/download.html</a></p>
<p>使用: <a target="_blank" rel="noopener" href="https://cxf.apache.org/docs/tools.html">https://cxf.apache.org/docs/tools.html</a></p>
<p><img src="/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/image-20230626133600677.png" alt="image-20230626133600677"></p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">wsdl2java -keep -encoding utf-8 -verbose http://10.123.10.213:8102/ws/hello?wsdl</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">wsdl2java -p com.cxfdemo -keep -encoding utf-8 -verbose http://10.123.10.213:8102/ws/autoDeptInfo?wsdl</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p><img src="/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/image-20230626113532687.png" alt="image-20230626113532687"></p>
<p><img src="/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/image-20230626113551595.png" alt="image-20230626113551595"></p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="keyword">package</span> com.cxfdemo.test;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.cxfdemo.DeptInfoWSServiceImpl;</span><br><span class="line"><span class="keyword">import</span> com.cxfdemo.DeptInfoWSServiceImplService;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>:</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span>: rsb</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>: 2023-06-26-11-46</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@description</span>:</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@Version</span>: 1.0.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MyCxfTest</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        DeptInfoWSServiceImplService wsService = <span class="keyword">new</span> DeptInfoWSServiceImplService();</span><br><span class="line">        DeptInfoWSServiceImpl serverPort = wsService.getDeptInfoWSServiceImplPort();</span><br><span class="line">        String msg = serverPort.getInfo();</span><br><span class="line">        System.out.println(<span class="string">&quot;远程调用ws服务成功:&quot;</span> + msg);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>2、使用CXF动态调用WS服务</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">无需生成代码，仅限第三方用java语言发布的WebService接口动态调用，不支持用.net发布的WebService接口</span><br></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://cxf.apache.org/docs/frontends.html">https://cxf.apache.org/docs/frontends.html</a></p>
<p><img src="/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/image-20230626160551627.png" alt="image-20230626160551627"></p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="meta">@RequestMapping(&quot;/getSettingInfo&quot;)</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> Object <span class="title">getSettingInfo</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    DynamicClientFactory clientFactory = DynamicClientFactory.newInstance();</span><br><span class="line">    Client client = clientFactory.createClient(<span class="string">&quot;http://127.0.0.1:8102/ws/autoSettingInfo?wsdl&quot;</span>);</span><br><span class="line">    Object[] objects;</span><br><span class="line">    Object object = <span class="keyword">null</span>;</span><br><span class="line">    Object[] params = <span class="keyword">new</span> Object[<span class="number">3</span>];</span><br><span class="line">    params[<span class="number">0</span>] = <span class="string">&quot;张三&quot;</span>;</span><br><span class="line">    params[<span class="number">1</span>] = <span class="string">&quot;888888888&quot;</span>;</span><br><span class="line">    params[<span class="number">2</span>] = <span class="string">&quot;男&quot;</span>;</span><br><span class="line">    <span class="keyword">try</span> &#123;</span><br><span class="line">        objects = client.invoke(<span class="string">&quot;getSettingInfo&quot;</span>, params);</span><br><span class="line">        <span class="keyword">if</span> (objects != <span class="keyword">null</span>) &#123;</span><br><span class="line">            object = objects[<span class="number">0</span>];</span><br><span class="line">        &#125;</span><br><span class="line">    &#125; <span class="keyword">catch</span> (Exception e) &#123;</span><br><span class="line">        e.printStackTrace();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> object;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>3、使用HttpClient直接发送xml报文的方式访问</p>
<p>请求报文:</p>
<figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">soapenv:Envelope</span> <span class="attr">xmlns:soapenv</span>=<span class="string">&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;</span> <span class="attr">xmlns:impl</span>=<span class="string">&quot;http://impl.service.ransibi.com/&quot;</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">soapenv:Header</span>/&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">soapenv:Body</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">impl:sayHello</span>&gt;</span></span><br><span class="line">         <span class="comment">&lt;!--Optional:--&gt;</span></span><br><span class="line">         <span class="tag">&lt;<span class="name">name</span>&gt;</span>世界<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">impl:sayHello</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;/<span class="name">soapenv:Body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">soapenv:Envelope</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>返回报文:</p>
<figure class="highlight xml"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">soap:Envelope</span> <span class="attr">xmlns:soap</span>=<span class="string">&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">soap:Body</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">ns2:sayHelloResponse</span> <span class="attr">xmlns:ns2</span>=<span class="string">&quot;http://impl.service.ransibi.com/&quot;</span>&gt;</span></span><br><span class="line">         <span class="tag">&lt;<span class="name">testName</span>&gt;</span>hello,世界<span class="tag">&lt;/<span class="name">testName</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;/<span class="name">ns2:sayHelloResponse</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;/<span class="name">soap:Body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">soap:Envelope</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>实现:</p>
<figure class="highlight java"><table><tr><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> String <span class="title">restTemplateActiveUsers</span><span class="params">()</span> </span>&#123;</span><br><span class="line">      <span class="comment">//构造webservice请求参数</span></span><br><span class="line">      StringBuffer soapRequestData = <span class="keyword">new</span> StringBuffer();</span><br><span class="line">      String s = <span class="string">&quot;世界&quot;</span>;</span><br><span class="line">      soapRequestData.append(<span class="string">&quot;&lt;soapenv:Envelope xmlns:soapenv=\&quot;http://schemas.xmlsoap.org/soap/envelope/\&quot; xmlns:impl=\&quot;http://impl.service.ransibi.com/\&quot;&gt;&quot;</span>);</span><br><span class="line">      soapRequestData.append(<span class="string">&quot;&lt;soapenv:Header/&gt;&quot;</span>);</span><br><span class="line">      soapRequestData.append(<span class="string">&quot;&lt;soapenv:Body&gt;&quot;</span>);</span><br><span class="line">      soapRequestData.append(<span class="string">&quot;&lt;impl:sayHello&gt;&quot;</span>);</span><br><span class="line">      soapRequestData.append(<span class="string">&quot;&lt;name&gt;&quot;</span>);</span><br><span class="line">      soapRequestData.append(s);</span><br><span class="line">      soapRequestData.append(<span class="string">&quot;&lt;/name&gt;&quot;</span>);</span><br><span class="line">      soapRequestData.append(<span class="string">&quot;&lt;/impl:sayHello&gt;&quot;</span>);</span><br><span class="line">      soapRequestData.append(<span class="string">&quot;&lt;/soapenv:Body&gt;&quot;</span>);</span><br><span class="line">      soapRequestData.append(<span class="string">&quot;&lt;/soapenv:Envelope&gt;&quot;</span>);</span><br><span class="line">      <span class="comment">//构造http请求头</span></span><br><span class="line">      HttpHeaders headers = <span class="keyword">new</span> HttpHeaders();</span><br><span class="line">      MediaType type = MediaType.parseMediaType(<span class="string">&quot;text/xml;charset=UTF-8&quot;</span>);</span><br><span class="line">      headers.setContentType(type);</span><br><span class="line">      HttpEntity&lt;String&gt; formEntity = <span class="keyword">new</span> HttpEntity&lt;&gt;(soapRequestData.toString(), headers);</span><br><span class="line">      <span class="comment">//返回结果</span></span><br><span class="line">      String resultStr = restTemplate.postForObject(omsWsdlAddress, formEntity, String.class);</span><br><span class="line">      <span class="keyword">return</span> resultStr;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<p><img src="/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/image-20230703160949770.png" alt="image-20230703160949770"></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://code-ran.gitee.io">牛牛</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://code-ran.gitee.io/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/">https://code-ran.gitee.io/2023/07/03/SpringBoot%E6%95%B4%E5%90%88WebService/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://code-ran.gitee.io" target="_blank">牛牛&blog</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/WebService%E7%9B%B8%E5%85%B3/">WebService相关</a></div><div class="post_share"><div class="social-share" data-image="" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2023/11/02/elementui%E8%A1%A8%E6%A0%BC%E7%9A%84%E8%A1%A8%E5%A4%B4%E5%A2%9E%E5%8A%A0%E6%82%AC%E6%B5%AE%E6%8F%90%E7%A4%BA/"><img class="prev-cover" src="" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">elementui表格的表头增加悬浮提示</div></div></a></div><div class="next-post pull-right"><a href="/2023/06/19/sql%E7%A7%AF%E7%B4%AF/"><img class="next-cover" src="" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">sql积累</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/ys.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">牛牛</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">52</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">26</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">26</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/code-ran"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">本blog内容仅用于个人学习使用!</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#SpringBoot%E6%95%B4%E5%90%88WebService"><span class="toc-number">1.</span> <span class="toc-text">SpringBoot整合WebService</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E4%B8%80%E3%80%81%E4%BD%BF%E7%94%A8JDK%E8%87%AA%E5%B8%A6%E7%9A%84JAX-WS%E5%8F%91%E5%B8%83WebService%E6%9C%8D%E5%8A%A1"><span class="toc-number">1.1.</span> <span class="toc-text">一、使用JDK自带的JAX-WS发布WebService服务</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E4%BA%8C%E3%80%81%E4%BD%BF%E7%94%A8CXF%E5%8F%91%E5%B8%83WebService%E6%9C%8D%E5%8A%A1"><span class="toc-number">1.2.</span> <span class="toc-text">二、使用CXF发布WebService服务</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E4%B8%89%E3%80%81%E5%8A%A8%E6%80%81%E5%8F%91%E5%B8%83%E5%A4%9A%E4%B8%AAWS%E6%9C%8D%E5%8A%A1"><span class="toc-number">1.3.</span> <span class="toc-text">三、动态发布多个WS服务</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E4%B8%89%E3%80%81%E6%9C%8D%E5%8A%A1%E6%B6%88%E8%B4%B9-%E5%AE%A2%E6%88%B7%E7%AB%AF"><span class="toc-number">1.4.</span> <span class="toc-text">三、服务消费(客户端)</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/04/30/springboot%E6%B3%A8%E8%A7%A3%E7%9B%B8%E5%85%B3/" title="springboot注解相关">springboot注解相关</a><time datetime="2024-04-30T03:20:37.000Z" title="发表于 2024-04-30 11:20:37">2024-04-30</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2024/04/30/CommandLineRunner%E5%92%8CApplicationRunner%E7%94%A8%E6%B3%95%E4%B8%8E%E5%8C%BA%E5%88%AB/" title="CommandLineRunner和ApplicationRunner用法与区别">CommandLineRunner和ApplicationRunner用法与区别</a><time datetime="2024-04-30T02:42:21.000Z" title="发表于 2024-04-30 10:42:21">2024-04-30</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/12/08/%E5%A5%BD%E6%96%87%E6%94%B6%E8%97%8F/" title="好文收藏">好文收藏</a><time datetime="2023-12-08T08:40:13.000Z" title="发表于 2023-12-08 16:40:13">2023-12-08</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/12/08/springboot%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0%E4%B8%8B%E8%BD%BD/" title="springboot文件上传下载">springboot文件上传下载</a><time datetime="2023-12-08T03:30:54.000Z" title="发表于 2023-12-08 11:30:54">2023-12-08</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/12/05/linux%E4%BD%BF%E7%94%A8curl%E5%91%BD%E4%BB%A4%E5%8F%91%E9%80%81%E8%AF%B7%E6%B1%82/" title="linux使用curl命令发送请求">linux使用curl命令发送请求</a><time datetime="2023-12-05T05:56:19.000Z" title="发表于 2023-12-05 13:56:19">2023-12-05</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2021 - 2024 By 牛牛</div><div class="footer_custom_text">Hi, Welcome to my blog!</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">簡</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>